package cn.ondraw.ragflow.controller;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import cn.ondraw.common.core.domain.R;
import cn.ondraw.ragflow.pojo.request.AgentListRequest;
import cn.ondraw.ragflow.service.AgentRagFlowService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 代理管理控制器
 */
@RestController
@Slf4j
@RequiredArgsConstructor
@RequestMapping
public class AgentRagFlowController {

    private final AgentRagFlowService agentRagFlowService;

    /**
     * 列出代理
     *
     * @param request 代理列表请求参数
     * @return 代理列表响应对象
     */
    @GetMapping("/v1/agents")
    public R<Object> listAgents(AgentListRequest request) {
        try {
            return R.ok(agentRagFlowService.listAgents(request));
        } catch (Exception e) {
            return R.fail(e.getMessage());
        }
    }
}
